@echo off
cls

set Server=waBISQL1
set DBName=BIMonitor
set Scripts=C:\BIMonitor\SQL\BIMonitor\


echo The BIMonitor database build SQL scripts are executing . . . . 
echo .



rem create database
sqlcmd -E -S %Server% -d "master" -i "%Scripts%Database\BIMonitor.sql"


rem create schemas
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Security\Schemas\BIMonitor.sql"


rem create tables
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.SQLAgentJobReportFilters.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.SQLAgentJobs_Extraction.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.SSISConfigurations.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.SSISProblemSummary.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.SSISServers.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.SystemHealth.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\BIMonitor.WMIQueries.sql"


rem load tables
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SSISConfigurations - ETL Environment.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SQLAgentJobReportFilters - Development.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SSISServers - Development.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.WMIQueries - Development.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SQLAgentJobReportFilters - UAT.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SSISServers - UAT.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.WMIQueries - UAT.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SQLAgentJobReportFilters - Production.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.SSISServers - Production.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Tables\Load\BIMonitor.WMIQueries - Production.sql"


rem create views
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Views\BIMonitor.SSISConfigurationSettings.sql"


rem create synonyms
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Synonyms\BIMonitor.SSISLog_Development.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Synonyms\BIMonitor.SSISLog_UAT.sql"
rem sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Synonyms\BIMonitor.SSISLog_Production.sql"


rem create procedures
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Procedures\BIMonitor.SQLAgentJobsReport.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Procedures\BIMonitor.SSISLogReport.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Procedures\BIMonitor.SSISProblemSummaryReport.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Procedures\BIMonitor.SSISProblemSummaryReportZeroRows.sql"
sqlcmd -E -S %Server% -d %DBName% -i "%Scripts%Procedures\BIMonitor.SystemHealthReport.sql"


echo .
echo .
echo The SQL scripts creating the Monitoring database and its objects completed.  Errors (if any) are listed above.
echo .
echo .
echo .
pause
